package com.demo.generate.code.config;

import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;

/**
 * 代码生成器配置类
 */
@Component
@ConfigurationProperties(prefix = "code.generator")
public class CodeGeneratorConfig {
    
    /**
     * 数据库配置
     */
    private Database database = new Database();
    
    /**
     * 生成配置
     */
    private Generator generator = new Generator();
    
    public static class Database {
        /**
         * 数据库连接URL
         */
        private String url;
        
        /**
         * 数据库用户名
         */
        private String username;
        
        /**
         * 数据库密码
         */
        private String password;
        
        /**
         * 数据库驱动类名
         */
        private String driverClassName;
        
        // Getters and Setters
        public String getUrl() {
            return url;
        }
        
        public void setUrl(String url) {
            this.url = url;
        }
        
        public String getUsername() {
            return username;
        }
        
        public void setUsername(String username) {
            this.username = username;
        }
        
        public String getPassword() {
            return password;
        }
        
        public void setPassword(String password) {
            this.password = password;
        }
        
        public String getDriverClassName() {
            return driverClassName;
        }
        
        public void setDriverClassName(String driverClassName) {
            this.driverClassName = driverClassName;
        }
    }
    
    public static class Generator {
        /**
         * 生成代码的包名基础路径
         */
        private String basePackage;
        
        /**
         * 作者
         */
        private String author = "CodeGenerator";
        
        /**
         * 是否生成Controller
         */
        private boolean generateController = true;
        
        /**
         * 是否生成Service
         */
        private boolean generateService = true;
        
        /**
         * 是否生成DAO
         */
        private boolean generateDao = true;
        
        /**
         * 是否生成Mapper XML
         */
        private boolean generateMapperXml = true;
        
        /**
         * 输出目录
         */
        private String outputDir = "./generated-code";
        
        // Getters and Setters
        public String getBasePackage() {
            return basePackage;
        }
        
        public void setBasePackage(String basePackage) {
            this.basePackage = basePackage;
        }
        
        public String getAuthor() {
            return author;
        }
        
        public void setAuthor(String author) {
            this.author = author;
        }
        
        public boolean isGenerateController() {
            return generateController;
        }
        
        public void setGenerateController(boolean generateController) {
            this.generateController = generateController;
        }
        
        public boolean isGenerateService() {
            return generateService;
        }
        
        public void setGenerateService(boolean generateService) {
            this.generateService = generateService;
        }
        
        public boolean isGenerateDao() {
            return generateDao;
        }
        
        public void setGenerateDao(boolean generateDao) {
            this.generateDao = generateDao;
        }
        
        public boolean isGenerateMapperXml() {
            return generateMapperXml;
        }
        
        public void setGenerateMapperXml(boolean generateMapperXml) {
            this.generateMapperXml = generateMapperXml;
        }
        
        public String getOutputDir() {
            return outputDir;
        }
        
        public void setOutputDir(String outputDir) {
            this.outputDir = outputDir;
        }
    }
    
    // Getters and Setters
    public Database getDatabase() {
        return database;
    }
    
    public void setDatabase(Database database) {
        this.database = database;
    }
    
    public Generator getGenerator() {
        return generator;
    }
    
    public void setGenerator(Generator generator) {
        this.generator = generator;
    }
}